package com.yenlien.traceyun.control.view;


import com.yenlien.traceyun.control.entity.ModelCategory;
import com.yenlien.traceyun.control.entity.ModelCrop;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-11-18
 * @description:
 **/
public class ModelCategoryTree {

    private String id;

    private String name;

    private String displayImg;

    private String code;

    private String parentId;

    private int type;

    private List<ModelCategoryTree> children = new ArrayList<>();


    public static ModelCategoryTree create(ModelCategory modelCategory) {
        ModelCategoryTree tree = new ModelCategoryTree();
        tree.setId(modelCategory.getId());
        tree.setName(modelCategory.getName());
        tree.setDisplayImg(modelCategory.getDisplayImg());
        tree.setCode(modelCategory.getCode());
        tree.setParentId(modelCategory.getParentId());
        tree.setType(modelCategory.getType());
        return tree;
    }

    public static List<ModelCategoryTree> create(List<ModelCategory> modelCategories) {
        List<ModelCategoryTree> trees = new ArrayList<>();
        if (modelCategories != null && modelCategories.size() > 0) {
            for (ModelCategory modelCategory : modelCategories) {
                trees.add(create(modelCategory));
            }
        }
        return trees;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDisplayImg() {
        return displayImg;
    }

    public void setDisplayImg(String displayImg) {
        this.displayImg = displayImg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public List<ModelCategoryTree> getChildren() {
        return children;
    }

    public void setChildren(List<ModelCategoryTree> children) {
        this.children = children;
    }

}
